package com.second.lease.controller;

import com.second.common.pojo.R;
import com.second.lease.pojo.entity.Car;
import com.second.lease.pojo.vo.AppQueryCarVO;
import com.second.lease.pojo.vo.QueryCarDate;
import com.second.lease.service.CarService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/car")
public class CarController {

    @Resource
    private CarService carService;

    @ApiOperation("查询所有车辆")
    @RequestMapping("/selectCar")
    public R selectCar(QueryCarDate queryCarDate){

        return carService.selectCar(queryCarDate);
    }
    @ApiOperation("根据类型查询所有车辆")
    @RequestMapping("/showCar")
    public R showCar(AppQueryCarVO appQueryCarVO){

        return carService.showCar(appQueryCarVO);
    }

    @ApiOperation("/更新车辆")
    @RequestMapping("/updateCar")
    public R updateCar(@RequestBody Car car) {
        return carService.updateCar(car);
    }

    @ApiOperation("/新增车辆")
    @RequestMapping("/addCar")
    public R addCar(@RequestBody Car car) {
        return carService.insertCar(car);
    }

    @ApiOperation("/删除车辆")
    @RequestMapping("/deleteCar")
    public R deleteCar(Integer id) {
        return carService.deleteCar(id);
    }
}
